package com.bridge.bridge_wd.activity;

import android.view.View;

import com.bigkoo.pickerview.OptionsPickerView;
import com.bridge.bridge_wd.R;
import com.bridge.bridge_wd.databinding.ActivitySetmibaoBinding;
import com.bridge.common.base.BaseActivity;
import com.bridge.common.utils.UltimateBarXUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName SetMiBaoActivity
 * @Description TODO消息
 * @Author xushufeng
 * @CreateDate 2021/4/18 0018 11:51
 * @Version 1.0
 * @UpdateDate 2021/4/18 0018 11:51
 * @UpdateRemark 更新说明
 */
public class SetMiBaoActivity extends BaseActivity {
    ActivitySetmibaoBinding binding;

    @Override
    protected int layoutId() {
        return R.layout.activity_setmibao;
    }

    @Override
    protected void initView() {
        binding = getBind();
        UltimateBarXUtils.setAppBar(this, true, true, R.color.color_f5f5f5);
        binding.linearMibaoWenti.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);
        if (view.getId() == R.id.linear_mibao_wenti) {
            showPickerView();
        }

    }

    @Override
    protected void setListenner() {

    }

    /**
     * 展示选择器
     * 核心代码
     */
    private void showPickerView() {
//      要展示的数据
        final List<String> listData = getData();
//      监听选中
        OptionsPickerView pvOptions = new OptionsPickerView.Builder(SetMiBaoActivity.this, new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int options2, int options3, View v) {
                binding.tvMibaowenti.setText(listData.get(options1));
            }
        }).setSelectOptions(1).setOutSideCancelable(false).setCancelText("取消").setCancelColor(getResources().getColor(R.color.color_24c36b))
                .setSubmitColor(getResources().getColor(R.color.color_24c36b)).setTitleText("选择问题")
                .setTitleSize(16).build();
        pvOptions.setPicker(listData);

        pvOptions.show();
    }

    /**
     * 造一组数据
     */
    private List getData() {
        List list = new ArrayList<>();
        for (int i = 0; i < 4; i++) {
            if (i == 0) {
                list.add("你的好友名字叫啥?");
            }
            if (i == 1) {
                list.add("您的生日?");
            }
            if (i == 2) {
                list.add("你最幸运的数字?");
            }
            if (i == 3) {
                list.add("您的同学是谁?");
            }

        }
        return list;

    }

}
